<?php
class Shout extends CI_Model {

	function __construct() {
		parent::__construct();
		
	}
	
	function all_shouts() {
		
		$world = $this->load->database('world', TRUE);
		
		$data = array();
		$world->order_by('id', 'DESC');
		$q = $world->get('shouts', 10);
		
		if ($q->num_rows() > 0) {
			foreach ($q->result() as $row) {
				$data[] = $row;
			}
		}
		
		return $data;
		$q->free_result();
	}
	
	function create() {
		$world = $this->load->database('world', TRUE);
		$data = array(
			'name'		=>	$this->form_validation->set_value('name'),
			'email'		=>	$this->form_validation->set_value('email'),
			'message'	=>	$this->form_validation->set_value('message')
		);
		$world->insert('shouts', $data);
	}

} 